﻿<Window x:Class="QuickTweet.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
        xmlns:behaviors="clr-namespace:QuickTweet.Common.Behaviors;assembly=QuickTweet.Common"
        xmlns:tb="http://www.hardcodet.net/taskbar"
        xmlns:local="clr-namespace:QuickTweet"
        xmlns:viewmodels="clr-namespace:QuickTweet.ViewModels"
        Title="Quick Tweet Options" Height="350" Width="525" Visibility="Hidden" 
        Icon="/QuickTweet;component/Icons/AppIcon_Large.ico"
        WindowStartupLocation="CenterScreen" Closing="Window_Closing" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}">
    <i:Interaction.Behaviors>
        <behaviors:WindowCloseBehavior CloseCommand="{Binding CloseCommand}" OKCloseButton="{Binding ElementName=OKButton}" CancelCloseButton="{Binding ElementName=CancelButton}" />
    </i:Interaction.Behaviors>
    <Window.Resources>
        <DataTemplate x:Key="ListViewItemTemplate">
            <StackPanel Orientation="Horizontal">
                <Image Source="{Binding Path=Image}" Margin="0 0 6 0"></Image>
                <TextBlock Text="{Binding Path=Text}" VerticalAlignment="Center"></TextBlock>
            </StackPanel>
        </DataTemplate>
        <Style TargetType="ListBoxItem">
            <Setter Property="HorizontalContentAlignment" Value="Stretch" />
            <Setter Property="FocusVisualStyle" Value="{x:Null}" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ListBoxItem">
                        <Border Name="Border" SnapsToDevicePixels="true" BorderThickness="1" Background="Transparent" Padding="2">
                            <ContentPresenter />
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger SourceName="Border" Property="IsMouseOver" Value="true">
                                <Setter TargetName="Border" Property="Background" Value="#AAA1CEF7"/>
                                <Setter TargetName="Border" Property="BorderBrush" Value="#AA00CCCC"></Setter>
                            </Trigger>
                            <Trigger Property="IsSelected" Value="true">
                                <Setter TargetName="Border" Property="Background" Value="#AAA1CEF7"/>
                                <Setter TargetName="Border" Property="BorderBrush" Value="#AA0066CC"></Setter>
                            </Trigger>
                            <!--<EventTrigger SourceName="Border" RoutedEvent="MouseLeftButtonDown">
                                <BeginStoryboard x:Name="itemClick">
                                    <Storyboard>
                                        <ThicknessAnimation FillBehavior="HoldEnd" Storyboard.TargetName="Border" 
                                                            Storyboard.TargetProperty="Padding" To="3 2 3 2" Duration="0:0:0.1"></ThicknessAnimation>
                                    </Storyboard>
                                </BeginStoryboard>
                            </EventTrigger>
                            <EventTrigger SourceName="Border" RoutedEvent="MouseLeftButtonUp">
                                <StopStoryboard BeginStoryboardName="itemClick"></StopStoryboard>
                            </EventTrigger>-->
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style TargetType="Grid" x:Key="OptionsPane">
            <Setter Property="Visibility">
                <Setter.Value>
                    <MultiBinding Converter="{StaticResource VisibilityOnEqualValueConverter}">
                        <Binding Path="SelectedOption.Text"></Binding>
                        <Binding RelativeSource="{RelativeSource Self}" Path="Tag"/>
                    </MultiBinding>
                </Setter.Value>
            </Setter>
        </Style>
        <DataTemplate x:Key="AccountItemTemplate">
            <TextBlock Text="{Binding Path=Name}"></TextBlock>
        </DataTemplate>
    </Window.Resources>
    <Grid>
        <tb:TaskbarIcon x:Name="MyNotifyIcon"
            IconSource="Icons/AppIcon.ico"
            ToolTipText="Quick Tweet"            
            TrayPopupOpen="MyNotifyIcon_TrayBalloonTipShown"
            DoubleClickCommand="{Binding Path=ShowOptionsCommand}">
            <tb:TaskbarIcon.TrayPopup>
                <local:TweetPopup>
                    <local:TweetPopup.DataContext>
                        <viewmodels:TweetPopupViewModel></viewmodels:TweetPopupViewModel>
                    </local:TweetPopup.DataContext>
                </local:TweetPopup>
            </tb:TaskbarIcon.TrayPopup>
            <tb:TaskbarIcon.ContextMenu>
                <ContextMenu>
                    <MenuItem Header="Go to Twitter..." Command="{Binding Path=GoToTwitterCommand}">
                        <MenuItem.Icon>
                            <Image Source="/QuickTweet;component/Icons/Twitter.gif" Height="16" Width="16" />
                        </MenuItem.Icon>
                    </MenuItem>
                    <MenuItem Header="Options..." Command="{Binding Path=ShowOptionsCommand}">
                        <MenuItem.Icon>
                            <Image Source="/QuickTweet;component/Icons/Properties.png" Height="16" Width="16" />
                        </MenuItem.Icon>
                    </MenuItem>
                    <Separator></Separator>
                    <MenuItem Header="About..." Command="{Binding Path=ShowAboutCommand}">
                        <MenuItem.Icon>
                            <Image Source="/QuickTweet;component/Icons/About.png" Height="16" Width="16" />
                        </MenuItem.Icon>
                    </MenuItem>
                    <Separator></Separator>
                    <MenuItem Header="Exit" Command="{Binding Path=ExitCommand}">
                    </MenuItem>
                </ContextMenu>
            </tb:TaskbarIcon.ContextMenu>
        </tb:TaskbarIcon>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="150"></ColumnDefinition>
                <ColumnDefinition Width="*"></ColumnDefinition>
            </Grid.ColumnDefinitions>
            <ListBox Margin="10" HorizontalContentAlignment="Stretch" ItemsSource="{Binding Path=Options}" ItemTemplate="{StaticResource ListViewItemTemplate}"
                      IsSynchronizedWithCurrentItem="True" SelectedItem="{Binding Path=SelectedOption, Mode=TwoWay}">
            </ListBox>
            <Grid Grid.Column="1">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="*"></RowDefinition>
                    <RowDefinition Height="Auto"></RowDefinition>
                </Grid.RowDefinitions>
                <TextBlock Margin="5 10 5 5" Text="{Binding Path=SelectedOption.Text}" Style="{StaticResource DefaultTextStyle}"></TextBlock>
                <Grid Grid.Row="1" Style="{StaticResource OptionsPane}" Tag="Settings" Margin="5">
                    <Button Content="Settings"/>
                </Grid>
                <Grid Grid.Row="1" Style="{StaticResource OptionsPane}" Tag="Accounts" Margin="5">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"></RowDefinition>
                        <RowDefinition Height="*"></RowDefinition>                        
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"></ColumnDefinition>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <TextBlock Text="Available Twitter Accounts:" Margin="0 0 5 5"></TextBlock>
                    <ListBox x:Name="lstAccounts" Grid.Row="1" ItemsSource="{Binding Path=Accounts}" HorizontalContentAlignment="Stretch" 
                            IsSynchronizedWithCurrentItem="True" SelectedItem="{Binding Path=CurrentAccount, Mode=TwoWay}" 
                             Width="250" HorizontalAlignment="Left" ItemTemplate="{StaticResource AccountItemTemplate}" />
                    <StackPanel Grid.Row="1" Grid.Column="1" Orientation="Vertical">
                        <Button Content="Add..." Margin="5 0 5 2" Command="{Binding Path=AddAccountCommand}"></Button>
                        <Button Content="Edit..." Margin="5 5 5 2" Command="{Binding Path=EditAccountCommand}"></Button>
                        <Button Content="Show" Margin="5 5 5 2" Command="{Binding Path=ShowAccountCommand}"></Button>
                        <Button Content="Delete..." Margin="5 15 5 2" Command="{Binding Path=DeleteAccountCommand}" CommandParameter="{Binding ElementName=lstAccounts, Path=SelectedIndex}"></Button>
                    </StackPanel>
                </Grid>
                <StackPanel Grid.Row="2" Margin="10" Orientation="Horizontal" HorizontalAlignment="Right">
                    <Button Content="OK" x:Name="OKButton" Margin="0 0 10 0" Command="{Binding Path=SaveCommand}" CommandParameter="OK"></Button>
                    <Button Content="Cancel" x:Name="CancelButton"  Margin="0 0 10 0"></Button>
                    <Button Content="Apply" Command="{Binding Path=SaveCommand}" CommandParameter="Apply"></Button>
                </StackPanel>
            </Grid>
        </Grid>
    </Grid>
</Window>
